package com.dkm.biz.gl.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.gl.domain.EavValueInt;
import com.dkm.biz.gl.persistence.dao.EavValueIntDao;
import com.dkm.biz.gl.persistence.dao.EavValueIntQueryDao;
import com.dkm.biz.gl.persistence.entity.EavValueIntPo;
import com.dkm.biz.gl.repository.EavValueIntRepository;
import com.dkm.biz.repository.AbstractRepository;

/**
 * 对象功能:属性值 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-19 10:20:53
 */
@Repository
public class EavValueIntRepositoryImpl extends AbstractRepository<String, EavValueIntPo,EavValueInt> implements EavValueIntRepository{
	  
	@Resource
	private  EavValueIntQueryDao eavValueIntQueryDao;
	
	@Resource
	private EavValueIntDao eavValueIntDao;

	public EavValueInt newInstance() {
		EavValueIntPo po = new EavValueIntPo();
		EavValueInt eavValueInt = SpringHelper.getBean(EavValueInt.class);
		eavValueInt.setData(po);
		return eavValueInt;
	}

	public EavValueInt newInstance(EavValueIntPo po) {
		EavValueInt eavValueInt = SpringHelper.getBean(EavValueInt.class);
		eavValueInt.setData(po);
		return eavValueInt;
	} 
	
	@Override
	protected IQueryDao<String, EavValueIntPo> getQueryDao() {
		return eavValueIntQueryDao;
	}
	public EavValueIntPo findByProdAttr(String entityId, String attrId){
		 Map<String,Object> params=new HashMap<String,Object>();
			params.put("entityId",entityId);
			params.put("attrId", attrId);
			return eavValueIntQueryDao.getByKey("findByProdAttr", params);
	}
	
	@Override
	public List<EavValueIntPo> findAllByEntityId(String entityId) {
		Map<String,Object> params=new HashMap<String,Object>();
		params.put("whereSql"," entity_id_='"+entityId+"'");
		return  eavValueIntQueryDao.findAll(params);
	}

	@Override
	public void update(String entityId, String attrKey, String attrValue) {
		eavValueIntDao.updateByEntityIdAndKey(entityId, attrKey, attrValue);
		
	}
}
